﻿using System;
using System.Runtime.CompilerServices;

namespace LearnTuple
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = ThreeResult();//用Item顺序指定值
            Console.WriteLine($"string={t.Item1},int={t.Item2},bool={t.Item3}");

            var (a, b, c) = ThreeResult();//接受时改别名
            Console.WriteLine($"string={a},int={b},bool={c}");

            var x = Xyz();
            Console.WriteLine($"x={x.x},y={x.y},z={x.z}");

            var (_, y, _) = Xyz();
            Console.WriteLine($"y={y}");

            var wdt = ValueTuple.Create<string, float, bool>("michel", 1999, true);
            Console.WriteLine($"{wdt.Item1},{wdt.Item2},{wdt.Item3}");

            Console.ReadKey();
        }

        static (string x, double y, bool z) Xyz()
        {
            return ("我是X", Math.PI, false);
        }

        //可以和上面一样简写 (string, int, bool)
        static ValueTuple<string, int, bool> ThreeResult()
        {
            return new ValueTuple<string, int, bool>("我是string", 521, true);
            //可简写 return ("我是string", 521, true); 
        }
    }
}
